package com.loongtech.bi.manager.pay;

import com.loongtech.bi.action.PageHelper;
import com.loongtech.bi.action.UIHelper;
import com.loongtech.bi.action.pay.UserPayAction;
import com.loongtech.bi.entity.pay.EntityNewUserLTV;
import com.loongtech.bi.entity.player.EntityNewUser;
import com.loongtech.bi.manager.player.NewUserManager;
import com.loongtech.bi.manager.system.BiPlatformManager;
import com.loongtech.bi.support.Helper;
import com.loongtech.bi.support.chart.*;
import com.loongtech.core.jpa.manager.ManagerQueryCacheBase;
import com.loongtech.core.util.Time;
import com.loongtech.core.util.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * 付费分析 —新玩家价值manager
 * 
 * @author marin
 * @date 2015-09-15
 */
@Service
public class UserPayManager extends ManagerQueryCacheBase<Object> {
	private static final long serialVersionUID = 1L;
	
	@Autowired
	NewUserManager newUserManager;
	@Autowired
	NewUserLTVManager newUserLTVManager;
	
	// 查询新玩家价值全部总体数据
	public List<EntityNewUserLTV> getAllUserPayValueData(Date dateStart, Date dateEnd) {
		return newUserLTVManager.getAllNewUserLTVByDate(dateStart, dateEnd);
	}

	// 更新汇总和价值数据
	public void updateData(List<EntityNewUserLTV> ltvs, Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<UserPayData> userPayData, ChartUIData userPayChart, List<UserPayValueData> userPayValueData, ChartUIData userPayValueChart) {
		Map<String, UserPayValueData> userPayValueDataMap = new LinkedHashMap<>();  // 用户创建日期=UserPayValueData
		// newUser
		Map<Integer, Integer> sumNewUserMap = new HashMap<Integer, Integer>() {
			private static final long serialVersionUID = 1L;
			{
				put(1, 0);put(2, 0);put(3, 0);put(4, 0);put(5, 0);put(6, 0);put(7, 0);put(8, 0);put(9, 0);put(10, 0);
				put(11, 0);put(12, 0);put(13, 0);put(14, 0);put(15, 0);put(16, 0);put(17, 0);put(18, 0);put(19, 0);put(20, 0);
				put(21, 0);put(22, 0);put(23, 0);put(24, 0);put(25, 0);put(26, 0);put(27, 0);put(28, 0);put(29, 0);put(30, 0);
				put(31, 0);put(32, 0);put(33, 0);put(34, 0);put(35, 0);put(36, 0);put(37, 0);put(38, 0);put(39, 0);put(40, 0);
				put(41, 0);put(42, 0);put(43, 0);put(44, 0);put(45, 0);put(46, 0);put(47, 0);put(48, 0);put(49, 0);put(50, 0);
				put(51, 0);put(52, 0);put(53, 0);put(54, 0);put(55, 0);put(56, 0);put(57, 0);put(58, 0);put(59, 0);put(60, 0);
			}
		};
		List<Object[]> list0 = newUserManager.getNewUserByAllKind(dateStart, dateEnd, queryPlatform, queryChannel, queryServer);
		if (list0 != null && list0.size() > 0 && list0.get(0)[0] != null) {
			for(Object[] o : list0) {
				String dateStr = o[0].toString();
				int newUser = Integer.parseInt(o[1].toString());
				
				setSumNewUser(sumNewUserMap, dateStr, newUser);  // 总新增
				
				UserPayValueData tmp = userPayValueDataMap.get(dateStr);
				if (tmp == null) {
					tmp = new UserPayValueData();
					tmp.setDateStr(dateStr);
					userPayValueDataMap.put(dateStr, tmp);
				}
				tmp.setNewUser(newUser);
			}
		}
		
		// ltv
		for (EntityNewUserLTV e: ltvs) {
			String startDay = e.getStartday();
			if(Time.formatDate(startDay, "yyyy-MM-dd").getTime() > dateEnd.getTime()) {  // 只处理用户创建时间在查询结束时间之前的
				continue;
			}
			
			// 汇总分日详细数据
			int d = Time.getInterval(Time.formatDate(startDay, "yyyy-MM-dd"), Time.formatDate(e.getEndday(), "yyyy-MM-dd")) + 1;  // 充值日与创建日相差天数
			boolean fuhe = queryPlatform.equals(e.getPlatformid()) && queryChannel.equals(e.getChannelid()) && queryServer.equals(e.getServerid());  // 是否符合查询条件
			if (fuhe && canRendered(d)) {
				UserPayValueData tmp2 = userPayValueDataMap.get(startDay);  // 详细数据map以用户创建时间为key
				if (tmp2 == null) {
					tmp2 = new UserPayValueData();
					tmp2.setDateStr(startDay);
					userPayValueDataMap.put(startDay, tmp2);
				}
				tmp2.setLtv(d, tmp2.getNewUser() == 0 ? 0 : PageHelper.floatKeepTwoNumber((float)(UIHelper.getYuan(e.getCashadd()) * 1.0 / tmp2.getNewUser())));
			}
		}
		
		// 更新最终详细数据和详细图表
		if (userPayValueDataMap.size() > 0) {
			userPayValueData.addAll(userPayValueDataMap.values());
			Collections.sort(userPayValueData, new UserPayValueData().comparatorDate);
			userPayValueChart.setJsonStr(new ChartTool(userPayValueData, UserPayValueData.class, "").loadData(userPayValueChart.getJsonType()));
		} else {
			userPayValueChart.setNull(true);
		}

        if (userPayValueData.size() > 0) {
            float[] fz = new float[16];
            int[] fm   = new int[16];
            for (UserPayValueData upvd : userPayValueData) {
                int d = Time.getInterval(Time.formatDate(upvd.getDateStr(), "yyyy-MM-dd"), Time.formatDate(Time.getDateStr(Time.currentDate()), "yyyy-MM-dd"));
                if (d >= 120) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();fz[11] += upvd.getThe28ltv();fz[12] += upvd.getThe30ltv();fz[13] += upvd.getThe60ltv();fz[14] += upvd.getThe90ltv();
                    fz[15] += upvd.getThe120ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;fm[11] += 1;
                    fm[12] += 1;fm[13] += 1;fm[14] += 1;fm[15] += 1;
                } else if (d >= 90) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();fz[11] += upvd.getThe28ltv();fz[12] += upvd.getThe30ltv();fz[13] += upvd.getThe60ltv();fz[14] += upvd.getThe90ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;fm[11] += 1;
                    fm[12] += 1;fm[13] += 1;fm[14] += 1;
                } else if (d >= 60) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();fz[11] += upvd.getThe28ltv();fz[12] += upvd.getThe30ltv();fz[13] += upvd.getThe60ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;fm[11] += 1;
                    fm[12] += 1;fm[13] += 1;
                } else if (d >= 30) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();fz[11] += upvd.getThe28ltv();fz[12] += upvd.getThe30ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;fm[11] += 1;
                    fm[12] += 1;
                } else if (d >= 28) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();fz[11] += upvd.getThe28ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;fm[11] += 1;
                }  else if (d >= 21) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fz[10] += upvd.getThe21ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;fm[10] += 1;
                }  else if (d >= 14) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();fz[9] += upvd.getThe14ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;fm[9] += 1;
                } else if (d >= 12) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();fz[8] += upvd.getThe12ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;fm[8] += 1;
                } else if (d >= 10) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();fz[7] += upvd.getThe10ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;fm[7] += 1;
                } else if (d >= 7) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();fz[6] += upvd.getThe7ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                    fm[6] += 1;
                } else if (d >= 6) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fz[5] += upvd.getThe6ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;fm[5] += 1;
                } else if (d >= 5) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();fz[4] += upvd.getThe5ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;fm[4] += 1;
                } else if (d >= 4) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();fz[3] += upvd.getThe4ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;fm[3] += 1;
                } else if (d >= 3) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();fz[2] += upvd.getThe3ltv();
                    fm[0] += 1;fm[1] += 1;fm[2] += 1;
                } else if (d >= 2) {
                    fz[0] += upvd.getThe1ltv();fz[1] += upvd.getThe2ltv();
                    fm[0] += 1;fm[1] += 1;
                } else if (d >= 1) {
                    fz[0] += upvd.getThe1ltv();
                    fm[0] += 1;
                }
            }

            for (int i = 0; i < fm.length; i++) {
                if (fm[i] == 0) {
                    break;
                }

                UserPayData v = new UserPayData();
                v.setId(i + 1);
                v.setName(v.getId() + "日LTV");
                v.setLtv(PageHelper.floatKeepTwoNumber(fz[i] * 1.0 / fm[i]));

                userPayData.add(v);
            }
            
            Collections.sort(userPayData, new UserPayData().comparatorIdRevise);
            userPayChart.setJsonStr(new ChartTool(userPayData, UserPayData.class, "").loadData(userPayChart.getJsonType()));
            Collections.sort(userPayData, new UserPayData().comparatorId);
        } else {
            userPayChart.setNull(true);
        }
	}
	private void setSumNewUser(Map<Integer, Integer> sunNewUserMap, String dateStr, int newUser) {
		int d = Time.getInterval(Time.formatDate(dateStr, "yyyy-MM-dd"), new Date()) + 1;
		for (int i = 1; i <= d; i++) {
			Integer tmp = sunNewUserMap.get(i);
			if (tmp != null) {
				sunNewUserMap.put(i, tmp + newUser);
			}
		}
	}
	
	// 更新对比数据
	public void updateData2(String compareTab, List<EntityNewUserLTV> ltvs, Date dateStart, Date dateEnd, String queryPlatform, String queryChannel, String queryServer, List<UserPayCompareData> userPayCompareData, ChartUIData userPayCompareChart) {
		Map<String, UserPayCompareData> resultMap = new LinkedHashMap<>();  // 分类(平台id、渠道id、区服id)=UserPayCompareData
		
		boolean isAllPCS = Utils.isAllPCS(queryPlatform, queryChannel, queryServer);  // 查询条件是否为全平台全渠道全服
		
		// 更新符合条件的对象的新增帐号数
		List<EntityNewUser> list = newUserManager.getNewUsersByDate(dateStart, dateEnd);
		if (!Helper.isEmptyValue(list)) {
			for (EntityNewUser e : list) {
				String platformid = e.getPlatformid();
				String channelid = e.getChannelid();
				String serverid = e.getServerid();
				String key = UserPayAction.platformCompareTab.equals(compareTab) ? platformid : (UserPayAction.channelCompareTab.equals(compareTab) ? channelid : serverid);
				String classStr = UserPayAction.platformCompareTab.equals(compareTab) ? BiPlatformManager.getPlatformNameById(key) : (UserPayAction.channelCompareTab.equals(compareTab) ? BiPlatformManager.getChannelNameById(key) : BiPlatformManager.getServerNameById(key));
				boolean fuhe = queryPlatform.equals(platformid) && queryChannel.equals(channelid) && queryServer.equals(serverid);  // 是否符合查询条件
				
				boolean ok = isAllPCS ? !"0".equals(key) : fuhe;  // 查询条件为全平台全渠道全区服，取不等于0的；查询条件为平台渠道区服某条件，取符合的
				if (ok) {
					UserPayCompareData tmp = resultMap.get(key);
					if (tmp == null) {
						tmp = new UserPayCompareData();
						tmp.setClassStr(classStr);
						resultMap.put(key, tmp);
					}
					tmp.setNewUser(tmp.getNewUser() + e.getNew_user());
				}
			}
		} else {
			userPayCompareChart.setNull(true);
			return;
		}
		
		// 更新符合条件的对象的指标值
		for (EntityNewUserLTV e: ltvs) {
			int d = Time.getInterval(Time.formatDate(e.getStartday(), "yyyy-MM-dd"), Time.formatDate(e.getEndday(), "yyyy-MM-dd")) + 1;  // 充值日与创建日相差天数
			String platformid= e.getPlatformid();
			String channelid = e.getChannelid();
			String serverid = e.getServerid();
			String key = UserPayAction.platformCompareTab.equals(compareTab) ? platformid : (UserPayAction.channelCompareTab.equals(compareTab) ? channelid : serverid);
			String classStr = UserPayAction.platformCompareTab.equals(compareTab) ? BiPlatformManager.getPlatformNameById(key) : (UserPayAction.channelCompareTab.equals(compareTab) ? BiPlatformManager.getChannelNameById(key) : BiPlatformManager.getServerNameById(key));
			boolean fuhe = queryPlatform.equals(platformid) && queryChannel.equals(channelid) && queryServer.equals(serverid);  // 是否符合查询条件
			
			boolean ok = isAllPCS ? !"0".equals(key) : fuhe;  // 查询条件为全平台全渠道全区服，取不等于0的；查询条件为平台渠道区服某条件，取符合的
			if (ok) {
				UserPayCompareData tmp = resultMap.get(key);
				if (tmp == null) {
					tmp = new UserPayCompareData();
					tmp.setClassStr(classStr);
					resultMap.put(key, tmp);
				}
				tmp.setLtv(d, tmp.getNewUser() == 0 ? 0 : (float)(UIHelper.getYuan(e.getCashadd()) * 1.0 / tmp.getNewUser()));
			}
		}
		
		// 更新最终数据和图表
		if (resultMap.size() > 0) {
			for (UserPayCompareData t : resultMap.values()) {
				t.formatLtv();  // 格式化数据
				userPayCompareData.add(t);
			}
			Collections.sort(userPayCompareData, new UserPayCompareData().comparatorClass);
			userPayCompareChart.setJsonType(ChartType.BAR2.type);
			userPayCompareChart.setJsonStr(new ChartTool(userPayCompareData, UserPayCompareData.class, "").loadData(ChartType.BAR.type));
		} else {
			userPayCompareChart.setNull(true);
		}
	}
	
	// 新玩家价值总体数据
	public static boolean canRendered(int id) {
		return (id >= 1 && id <= 7) || (id == 10) || (id == 12) || (id == 14) || (id == 21) || (id == 28) || (id == 30) || (id == 60) || (id == 90) || (id == 120);
	}
	public class UserPayData {
		@ChartFlow(name="ltv")
		private String name; // 名称
		private int id; // 用于排序
		private long payUser;  // 付费用户
		private long pay;  // 付费额
		@ChartSelect(name = "LTV", key = 1)
		@ChartData1(name = "LTV值", key = 1)
		private float ltv; // ltv值
		private boolean rendered = true;  // 是否在前端表格中显示

		public final Comparator<UserPayData> comparatorId = new Comparator<UserPayData>() {
			public int compare(UserPayData s2, UserPayData s1) {
				return new Integer(s2.getId()).compareTo(s1.getId());
			}
		};
		public final Comparator<UserPayData> comparatorIdRevise = new Comparator<UserPayData>() {
			public int compare(UserPayData s2, UserPayData s1) {
				return new Integer(s1.getId()).compareTo(new Integer(s2.getId()));
			}
		};
		
		public float getLtv() {
			return ltv;
		}

		public void setLtv(float ltv) {
			this.ltv = ltv;
		}

		public int getId() {
			return id;
		}

		public void setId(int id) {
			this.id = id;
			rendered = canRendered(id);
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public boolean isRendered() {
			return rendered;
		}

		public void setRendered(boolean rendered) {
			this.rendered = rendered;
		}

		public long getPay() {
			return pay;
		}

		public void setPay(long pay) {
			this.pay = pay;
		}

		public long getPayUser() {
			return payUser;
		}

		public void setPayUser(long payUser) {
			this.payUser = payUser;
		}
	}
	
	// 新玩家价值数据类，Chart类
	public class UserPayValueData {
		@ChartFlow(name="日期")
		private String dateStr;
		private int newUser;  // 新增用户
		private float the1ltv; // 1日LTV
		private float the2ltv; // 2日LTV
		private float the3ltv; // 3日LTV
		private float the4ltv; // 4日LTV
		private float the5ltv; // 5日LTV
		private float the6ltv; // 6日LTV
		@ChartSelect(name = "LTV", key = 1)
		@ChartData1(name = "7日LTV", key = 1)
		private float the7ltv; // 7日LTV
		@ChartData1(name = "10日LTV", key = 1)
		private float the10ltv; // 10日LTV
		@ChartData1(name = "12日LTV", key = 1)
		private float the12ltv; // 12日LTV
		@ChartData1(name = "14日LTV", key = 1)
		private float the14ltv; // 14日LTV
		@ChartData1(name = "21日LTV", key = 1)
		private float the21ltv; // 21日LTV
		@ChartData1(name = "28日LTV", key = 1)
		private float the28ltv; // 28日LTV
		@ChartData1(name = "30日LTV", key = 1)
		private float the30ltv; // 30日LTV
		@ChartData1(name = "60日LTV", key = 1)
		private float the60ltv; // 60日LTV
		@ChartData1(name = "90日LTV", key = 1)
		private float the90ltv; // 90日LTV
		@ChartData1(name = "120日LTV", key = 1)
		private float the120ltv; // 120日LTV

		public final Comparator<UserPayValueData> comparatorDate = new Comparator<UserPayValueData>() {
			public int compare(UserPayValueData s1, UserPayValueData s2) {
				return s2.getDateStr().compareTo(s1.getDateStr());
			}
		};
		
		public void setLtv(int id, float ltv) {
			if (id == 1) {
				the1ltv = ltv;
			} else if (id == 2) {
				the2ltv = ltv;
			} else if (id == 3) {
				the3ltv = ltv;
			} else if (id == 4) {
				the4ltv = ltv;
			} else if (id == 5) {
				the5ltv = ltv;
			} else if (id == 6) {
				the6ltv = ltv;
			} else if (id == 7) {
				the7ltv = ltv;
			} else if (id == 10) {
				the10ltv = ltv;
			} else if (id == 12) {
				the12ltv = ltv;
			} else if (id == 14) {
				the14ltv = ltv;
			} else if (id == 21) {
				the21ltv = ltv;
			} else if (id == 28) {
				the28ltv = ltv;
			} else if (id == 30) {
				the30ltv = ltv;
			} else if (id == 60) {
				the60ltv = ltv;
			} else if (id == 90) {
				the90ltv = ltv;
			} else if (id == 120) {
				the120ltv = ltv;
			}
		}
		
		public float getThe21ltv() {
			return the21ltv;
		}

		public void setThe21ltv(float the21ltv) {
			this.the21ltv = the21ltv;
		}

		public float getThe28ltv() {
			return the28ltv;
		}

		public void setThe28ltv(float the28ltv) {
			this.the28ltv = the28ltv;
		}

		public String getDateStr() {
			return dateStr;
		}

		public void setDateStr(String dateStr) {
			this.dateStr = dateStr;
		}
		
		public float getThe1ltv() {
			return the1ltv;
		}

		public void setThe1ltv(float the1ltv) {
			this.the1ltv = the1ltv;
		}

		public float getThe2ltv() {
			return the2ltv;
		}

		public void setThe2ltv(float the2ltv) {
			this.the2ltv = the2ltv;
		}

		public float getThe3ltv() {
			return the3ltv;
		}

		public void setThe3ltv(float the3ltv) {
			this.the3ltv = the3ltv;
		}

		public float getThe4ltv() {
			return the4ltv;
		}

		public void setThe4ltv(float the4ltv) {
			this.the4ltv = the4ltv;
		}

		public float getThe5ltv() {
			return the5ltv;
		}

		public void setThe5ltv(float the5ltv) {
			this.the5ltv = the5ltv;
		}

		public float getThe6ltv() {
			return the6ltv;
		}

		public void setThe6ltv(float the6ltv) {
			this.the6ltv = the6ltv;
		}

		public float getThe7ltv() {
			return the7ltv;
		}

		public void setThe7ltv(float the7ltv) {
			this.the7ltv = the7ltv;
		}

		public float getThe14ltv() {
			return the14ltv;
		}

		public void setThe14ltv(float the14ltv) {
			this.the14ltv = the14ltv;
		}

		public float getThe30ltv() {
			return the30ltv;
		}

		public void setThe30ltv(float the30ltv) {
			this.the30ltv = the30ltv;
		}

		public float getThe60ltv() {
			return the60ltv;
		}

		public void setThe60ltv(float the60ltv) {
			this.the60ltv = the60ltv;
		}

		public int getNewUser() {
			return newUser;
		}

		public void setNewUser(int newUser) {
			this.newUser = newUser;
		}

		public float getThe90ltv() {
			return the90ltv;
		}

		public void setThe90ltv(float the90ltv) {
			this.the90ltv = the90ltv;
		}

		public float getThe120ltv() {
			return the120ltv;
		}

		public void setThe120ltv(float the120ltv) {
			this.the120ltv = the120ltv;
		}

		public float getThe10ltv() {
			return the10ltv;
		}

		public void setThe10ltv(float the10ltv) {
			this.the10ltv = the10ltv;
		}

		public float getThe12ltv() {
			return the12ltv;
		}

		public void setThe12ltv(float the12ltv) {
			this.the12ltv = the12ltv;
		}
	}
	
	// 新玩家价值对比数据类，Chart类
	public class UserPayCompareData {
		@ChartFlow(name="分类")
		private String classStr;  // 分类，选平台，就是所有平台，选渠道，就是所有渠道，选区服，就是所有区服
		private int newUser;  // 新增用户
		private float the1ltv; // 1日LTV
		private float the2ltv; // 2日LTV
		private float the3ltv; // 3日LTV
		private float the4ltv; // 4日LTV
		private float the5ltv; // 5日LTV
		private float the6ltv; // 6日LTV
		@ChartSelect(name = "LTV", key = 1)
		@ChartData1(name = "7日LTV", key = 1)
		private float the7ltv; // 7日LTV
		@ChartData1(name = "10日LTV", key = 1)
		private float the10ltv; // 10日LTV
		@ChartData1(name = "12日LTV", key = 1)
		private float the12ltv; // 12日LTV
		@ChartData1(name = "14日LTV", key = 1)
		private float the14ltv; // 14日LTV
		@ChartData1(name = "21日LTV", key = 1)
		private float the21ltv; // 21日LTV
		@ChartData1(name = "28日LTV", key = 1)
		private float the28ltv; // 28日LTV
		@ChartData1(name = "30日LTV", key = 1)
		private float the30ltv; // 30日LTV
		@ChartData1(name = "60日LTV", key = 1)
		private float the60ltv; // 60日LTV
		@ChartData1(name = "90日LTV", key = 1)
		private float the90ltv; // 90日LTV
		@ChartData1(name = "120日LTV", key = 1)
		private float the120ltv; //120日LTV
		
		public final Comparator<UserPayCompareData> comparatorClass = new Comparator<UserPayCompareData>() {
			public int compare(UserPayCompareData s1, UserPayCompareData s2) {
				return s1.getClassStr().compareTo(s1.getClassStr());
			}
		};
		
		public void formatLtv() {
			the1ltv = PageHelper.floatKeepTwoNumber(the1ltv);
			the2ltv = PageHelper.floatKeepTwoNumber(the2ltv);
			the3ltv = PageHelper.floatKeepTwoNumber(the3ltv);
			the4ltv = PageHelper.floatKeepTwoNumber(the4ltv);
			the5ltv = PageHelper.floatKeepTwoNumber(the5ltv);
			the6ltv = PageHelper.floatKeepTwoNumber(the6ltv);
			the7ltv = PageHelper.floatKeepTwoNumber(the7ltv);
			the10ltv = PageHelper.floatKeepTwoNumber(the10ltv);
			the12ltv = PageHelper.floatKeepTwoNumber(the12ltv);
			the14ltv = PageHelper.floatKeepTwoNumber(the14ltv);
			the21ltv = PageHelper.floatKeepTwoNumber(the21ltv);
			the28ltv = PageHelper.floatKeepTwoNumber(the28ltv);
			the30ltv = PageHelper.floatKeepTwoNumber(the30ltv);
			the60ltv = PageHelper.floatKeepTwoNumber(the60ltv);
			the90ltv = PageHelper.floatKeepTwoNumber(the90ltv);
			the120ltv = PageHelper.floatKeepTwoNumber(the120ltv);
		}
		
		public void setLtv(int id, float ltv) {
			if (id == 1) {
				the1ltv += ltv;
			} else if (id == 2) {
				the2ltv += ltv;
			} else if (id == 3) {
				the3ltv += ltv;
			} else if (id == 4) {
				the4ltv += ltv;
			} else if (id == 5) {
				the5ltv += ltv;
			} else if (id == 6) {
				the6ltv += ltv;
			} else if (id == 7) {
				the7ltv += ltv;
			} else if (id == 10) {
				the10ltv += ltv;
			} else if (id == 12) {
				the12ltv += ltv;
			} else if (id == 14) {
				the14ltv += ltv;
			} else if (id == 21) {
				the21ltv += ltv;
			} else if (id == 28) {
				the28ltv += ltv;
			} else if (id == 30) {
				the30ltv += ltv;
			} else if (id == 60) {
				the60ltv += ltv;
			} else if (id == 90) {
				the90ltv += ltv;
			} else if (id == 120) {
				the120ltv += ltv;
			}
		}

		public String getClassStr() {
			return classStr;
		}

		public void setClassStr(String classStr) {
			this.classStr = classStr;
		}
		
		public float getThe1ltv() {
			return the1ltv;
		}

		public void setThe1ltv(float the1ltv) {
			this.the1ltv = the1ltv;
		}

		public float getThe2ltv() {
			return the2ltv;
		}

		public void setThe2ltv(float the2ltv) {
			this.the2ltv = the2ltv;
		}

		public float getThe3ltv() {
			return the3ltv;
		}

		public void setThe3ltv(float the3ltv) {
			this.the3ltv = the3ltv;
		}

		public float getThe4ltv() {
			return the4ltv;
		}

		public void setThe4ltv(float the4ltv) {
			this.the4ltv = the4ltv;
		}

		public float getThe5ltv() {
			return the5ltv;
		}

		public void setThe5ltv(float the5ltv) {
			this.the5ltv = the5ltv;
		}

		public float getThe6ltv() {
			return the6ltv;
		}

		public void setThe6ltv(float the6ltv) {
			this.the6ltv = the6ltv;
		}

		public float getThe7ltv() {
			return the7ltv;
		}

		public void setThe7ltv(float the7ltv) {
			this.the7ltv = the7ltv;
		}

		public float getThe14ltv() {
			return the14ltv;
		}

		public void setThe14ltv(float the14ltv) {
			this.the14ltv = the14ltv;
		}

		public float getThe30ltv() {
			return the30ltv;
		}

		public void setThe30ltv(float the30ltv) {
			this.the30ltv = the30ltv;
		}

		public float getThe60ltv() {
			return the60ltv;
		}

		public void setThe60ltv(float the60ltv) {
			this.the60ltv = the60ltv;
		}

		public int getNewUser() {
			return newUser;
		}

		public void setNewUser(int newUser) {
			this.newUser = newUser;
		}

		public float getThe90ltv() {
			return the90ltv;
		}

		public void setThe90ltv(float the90ltv) {
			this.the90ltv = the90ltv;
		}

		public float getThe120ltv() {
			return the120ltv;
		}

		public void setThe120ltv(float the120ltv) {
			this.the120ltv = the120ltv;
		}

		public float getThe10ltv() {
			return the10ltv;
		}

		public void setThe10ltv(float the10ltv) {
			this.the10ltv = the10ltv;
		}

		public float getThe12ltv() {
			return the12ltv;
		}

		public void setThe12ltv(float the12ltv) {
			this.the12ltv = the12ltv;
		}

		public float getThe21ltv() {
			return the21ltv;
		}

		public void setThe21ltv(float the21ltv) {
			this.the21ltv = the21ltv;
		}

		public float getThe28ltv() {
			return the28ltv;
		}

		public void setThe28ltv(float the28ltv) {
			this.the28ltv = the28ltv;
		}
	}
}